﻿using Site.Business.Interfaces;
using Site.Business.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Dapper;

namespace Site.Data
{
    public class UserRepository: IUserRepository
    {
        private readonly IDbConnectionFactory _dbConnectionFactory;

        public UserRepository(IDbConnectionFactory dbConnectionFactory)
        {
            _dbConnectionFactory = dbConnectionFactory;
        }

        public IEnumerable<User> GetUsers()
        {
            using (var dbConnection = _dbConnectionFactory.CreateConnection())
            {
               // return connection.Query<ApplicationUser>("select * from Users where UserId = @userId", new { userId = parsedUserId }).SingleOrDefault();
                return SqlMapper.Query<User>(dbConnection, "select * from Users where UserName = \'karan1981\'");
            }
        }
    }
}
